import java.awt.Color;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;


public class ClientPoker extends JFrame{
	
	final int PORT = 50000;
	final String HOST = "localhost";
	JLabel lID, lActualMoney;
	PrintWriter out;
    BufferedReader in;
    
	public ClientPoker () {
		setSize (750,750);
		setTitle ("Welcome in Poker game");
		setLayout(null);
		setForeground(Color.GREEN);
		
		JLabel lPlayerID = new JLabel ("PlayerID");
		lPlayerID.setBounds (0, 0, 100, 25);
		lPlayerID.setBackground(Color.GREEN);
		add(lPlayerID);
		
		lID = new JLabel ();
		lID.setBounds(100, 0, 100, 25);
		lID.setBackground(Color.GREEN);
		add (lID);
		
		JLabel lOwnedMoney = new JLabel ("Owned Money");
		lOwnedMoney.setBounds (0, 25, 100, 25);
		lOwnedMoney.setBackground(Color.GREEN);
		add(lOwnedMoney);
		
		lActualMoney = new JLabel ();
		lActualMoney.setBounds (100, 25, 100, 25);
		lActualMoney.setBackground(Color.GREEN);
		add(lActualMoney);
		
		try {
			Socket socket = new Socket (HOST, PORT);
			out = new PrintWriter(socket.getOutputStream(),true);  
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		} catch (Exception e) {
		
			JOptionPane.showMessageDialog(this, 
					"Could not connect to server " + HOST + " on port: " + PORT, "Error", JOptionPane.ERROR_MESSAGE);
			System.exit(1);
		}
		try {
			String input = in.readLine();
			lID.setText(input);
			input = in.readLine();
			lActualMoney.setText(input);
		}catch (IOException ioe) {
			lID.setText("DebugFailed");
		}
		
		
		
	}
	
	public static void main (final String args[]) {
		ClientPoker client = new ClientPoker ();
		client.setVisible(true);
		client.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

}
